package com.tamartech.planning;
import org.apache.log4j.Logger;

import com.tamartech.planning.exporter.MapDataCSVExporter;
import com.tamartech.planning.importer.OpenlyLocalImporter;
import com.tamartech.planning.uploader.FTPUploader;

public class PlanningClient
{
    private static Logger log = Logger.getLogger (PlanningClient.class);

    private static final String CSV_NAME = "markers.txt";
    private static final String CSV_LOCAL_PATH = "/dump";
    private static final String CSV_REMOTE_PATH = "/htdocs/redhillgreens/test";
    private static final String FTP_SERVER = "ftp5.bpweb.net";
    private static final String FTP_USERNAME = "junctioneight";
    private static final String FTP_PASSWORD = "R3alPa1nInTheAss";
    
    public static void main(String[] args)
    {
        try
        {
            OpenlyLocalImporter importer = new OpenlyLocalImporter();
            
            importer.run();
            
            MapDataCSVExporter exporter = new MapDataCSVExporter();
            
            exporter.setCsvPath(CSV_LOCAL_PATH);
            exporter.setCsvName(CSV_NAME);
            exporter.run();
            
            FTPUploader uploader = new FTPUploader();
            
            uploader.setLocalName(CSV_NAME);
            uploader.setLocalPath(CSV_LOCAL_PATH);
            uploader.setRemoteName(CSV_NAME);
            uploader.setRemotePath(CSV_REMOTE_PATH);
            uploader.setServer(FTP_SERVER);
            uploader.setUsername(FTP_USERNAME);
            uploader.setPassword(FTP_PASSWORD);
            
            uploader.run();
            
            log.info("Planning client completed successfully");
        }
        catch (Exception e)
        {
            log.error("Planning client failed", e);
        }
        
//        there are a couple apps in markers.txt in active proj dir. Could put those in db by hand
    }
}
